package javadany02;

public class Homework6HuiwenSushu {
	public static void main(String[] args){
		int count=0;
		for(int i=1;i<1000;i++){
			int hui=huiwen(i);
			int su=sushu(i);
			if(hui==1&&su==1){
				System.out.print(i+" ");
				count++;
				if(count==10){
					System.out.println();
					count=0;
				}
			}
		}
	}
	
	public static int huiwen(int num){
		int x=num;
		int s=0;
		while(x!=0){
			int j=x%10;
			s=s*10+j;
			x=x/10;
		}
		if(s==num){
			return 1;
		}
		return 0;
	}
	
	public static int sushu(int num){
		if(num==1){
			return 0;
		}
		for(int i=2;i<num;i++){
			if(num%i==0){
				return 0;
			}	
		}
		
		return 1;
	}

}
